package cn.wolfcode.p2p.bussness.domain;

import cn.wolfcode.p2p.base.domain.BaseAuthDomain;
import com.alibaba.fastjson.JSON;
import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;

import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

@Setter
@Getter
//线下充值单
public class RechargeOffline extends BaseAuthDomain {
    private PlatformBankInfo bankInfo;//平台账户

    private String tradeCode;//交易号

    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date rechargeDate;//交易日期

    private BigDecimal amount;//充值金额

    private String note;//备注信息

    public String getJsonString() {
        Map<String, Object> map = new HashMap<>();
        map.put("id", super.getId());
        map.put("username", super.getApplier().getUsername());
        map.put("tradeCode",tradeCode);
        map.put("amount",amount);
        //日期转换成字符串
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        map.put("rechargeDate",sdf.format(rechargeDate));
        return JSON.toJSONString(map);
    }
}
